//
//  BK_OD_MoneyDetail.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/3/10.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_OD_MoneyDetail.h"

#import "BK_OD_Color.h"

@implementation BK_OD_MoneyDetail

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    self.backgroundColor = [UIColor whiteColor];
    return self;
}

-(UILabel *) InitLabel:(NSString *)text Font:(UIFont *)font
{
    UILabel *label = [UILabel new];
    label.text = text;
    label.textColor = kOrderBlack1;
    label.font = font;
    label.backgroundColor = [UIColor clearColor];
    return label;
}

-(void) SetLeftControlsConstraints:(UILabel *)label
{
    [label mas_makeConstraints:^(MASConstraintMaker *make)
     {
         NSInteger number = [self.contentView subviews].count/2;
         make.top.mas_equalTo(self.contentView.mas_top).offset(number>0?26*number+10:10);
         make.left.mas_equalTo(self.contentView.mas_left).offset(ApplicationBackGauge);
         make.height.mas_equalTo(26);
     }];
}

-(void) SetRightControlsConstraints:(UILabel *)label LeftControls:(UILabel *)control
{
    [label mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.right.mas_equalTo(self.contentView.mas_right).offset(-ApplicationBackGauge);
         make.centerY.mas_equalTo(control.mas_centerY);
         make.height.mas_equalTo(26);
     }];
}

-(void)fillData:(id)data{
    BK_My_DetailOrder_CellModel *cellModel = data;
    BK_My_DetailOrder_Model *_centerModel = cellModel.OrderModel;
    
    for (UIView *view in [self.contentView subviews])
    {
        [view removeFromSuperview];
    }
    for(BK_My_DetailOrder_OrderAmountLableList_Model *listModel  in _centerModel.order_amount_lable_list)
    {
        UILabel *leftLabel = [self InitLabel:listModel.lableName Font:[UIFont systemFontOfSize:FONT_ORDER_Detail_ZHUTI]];
        [self.contentView addSubview:leftLabel];
        [self SetLeftControlsConstraints:leftLabel];
        
        UILabel *rightLabel = [self InitLabel:listModel.lableVaule Font:[UIFont systemFontOfSize:FONT_ORDER_Detail_XL]];
        [self.contentView addSubview:rightLabel];
        [self SetRightControlsConstraints:rightLabel LeftControls:leftLabel];
    }
    
}

@end


